<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>

</head>

<body>
    <div id="app">

        <h1>火车票购买:</h1>
        <p>for-in遍历数组</p>
        <ul>
            <li v-for="(object,index) in beds">
                <!-- {{bed.name}} -->
                {{object.name}}
                {{index}}

                <!-- <span v-html="bed.butt"></span> -->
            </li>

        </ul>
        <!-- for of 遍历数组,可以,好像用法也一样? -->
        <p>for-of遍历数组</p>
        <ul>
            <li v-for="(object,index) of beds">
                {{object.name}}
                {{index}}

            </li>

        </ul>

        <p>for-in遍历对象</p>
        <ul>
            <li v-for="(item,key,index) in beds[0]">
                {{item}}---{{key}}---{{index}}
            </li>
        </ul>
        <p>for-of遍历对象</p>
        <ul>
            <li v-for="(item,key,index) of beds[0]">
                {{item}}---{{key}}---{{index}}
            </li>
        </ul>
    </div>

</body>

<script>
    const vm = new Vue({
        el: "#app",
        data: {
            beds: [
                {
                    name: '上铺',
                    butt: '<button>购买</button>'
                },
                {
                    name: '中铺',
                    butt: '<button>购买</button>'
                },
                {
                    name: '下铺',
                    butt: '<button>购买</button>'
                },
            ]
        }
    });

</script>

</html>